<template>
	<view class="container">
		<!-- 空白页 -->
		<empty v-if="emptyShow" :custom="true" src="../../../static/images/no-orders.png" text="暂无相关套餐"></empty>
		<!-- 刺梨卡套餐 -->
		<view class="tratt">
			<!-- 头部 -->
			<view class="tapBox">
				<view class="cardListTab">
					<view class="left">
						<uni-icons type="back" size="20" color="#333" @click="goBack"></uni-icons>
						<text class="tit">套餐专区</text>
					</view>
					<view class="recode">
						<uni-icons type="search" size="20" color="#333"></uni-icons>
						<input type="text" value="" v-model="keyword" placeholder="刺梨1788套餐" placeholder-class="search" @confirm="init" />
						<icon type="clear" :size='13' color='#bcbcbc' @tap="cleanKey" v-if="keyword"></icon>
					</view>
				</view>
			</view>
			<!-- 套餐专区 -->
			<view class="contentes">
				<view class="set_list" v-for="(item,index) in  mealInfo" :key="index">
					<view class="item">
						<view class="top">
							<view class="contents">
								{{item.store_name}}
							</view>
						</view>
						<view class="boxs">
							<view class="items" v-for="(items,indexs) in item.attr" :key="indexs" @click=goPages(item,items)>
								<image :src="items.data.image" mode=""></image>
								<view class="product">
									<view class="names">{{items.title}}</view>
									<view class="price">
										<text class="tag">{{items.data.suk}}</text>
										<view class="money"><text class="text">￥</text>{{items.data.price}}</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="mores">
			<uni-load-more class="loadMore" iconType="circle" :status="loadStatus" :contentText="contentText"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import {
		trattMeal
	} from '../../../api/order.js'
	export default {
		data() {
			return {
				emptyShow: false,
				keyword: '', //搜索参数
				mealInfo: [], //套餐详情
				//--------翻页参数
				page: 1,
				loadStatus: "loading",
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
			}
		},
		components: {
			uniLoadMore
		},
		onLoad(options) {
			this.init()
		},
		onReachBottom() {
			// if (this.loadStatus == 'noMore') return;
			// this.loadStatus = "loading";
			// this.init();
		},
		methods: {
			// 初始数据
			init() {
				this.loadStatus = "loading";
				trattMeal({
					keyword: this.keyword
				}).then(res => {
					this.loadStatus = "noMore";
					this.mealInfo = res.data
					if (this.mealInfo.length == 0) {
						this.contentText.contentnomore = ''
						setTimeout(res => {
							this.emptyShow = true
						}, 1000)
					}else{
						this.emptyShow = false
						this.contentText.contentnomore = '没有更多了'
					}

				}).catch(err => {
					$model(err)
				})
			},
			goPages(item, items) {
				uni.navigateTo({
					url: `/pages/center/prickly/details?id=${item.id}&sku=${items.data.suk}`
				})
			},
			cleanKey: function() {
				this.keyword = ''
				this.init()
			},
			goBack() {
				uni.navigateBack()
			},
		}
	}
</script>

<style>
	page {
		background-color: #F6F6F6;
	}
</style>
<style lang="scss" scoped>
	.container {
		.tratt {
			position: relative;
			z-index: 99;
			//#ifdef APP-PLUS
			//#endif
			//#ifdef H5
			// padding-top: 20rpx;
			//#endif
			box-sizing: border-box;

			.tapBox {
				width: 100%;
				box-sizing: border-box;

				padding: calc(20rpx + var(--status-bar-height)) 30rpx 20rpx;

				background-color: #FAC11C;
				position: fixed;
				z-index: 9999;


				.cardListTab {
					width: 100%;
					height: auto;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.left {
						width: 250rpx;

						.tit {
							color: $uni-text-color;
							font-size: 36rpx;
							font-weight: bold;
							margin-left: 25rpx;
						}
					}

					.recode {
						flex: 1;
						height: 70rpx;
						background-color: #FCDD82;
						border-radius: 35rpx;
						padding: 0 34rpx;
						display: flex;
						justify-content: flex-start;
						align-items: center;

						input {
							margin-left: 15rpx;
						}

						.search {
							font-size: 30rpx;
							color: #666666;
						}
					}
				}
			}

			.contentes {
				//#ifdef APP-PLUS
				padding-top: calc(110rpx + var(--status-bar-height));
				//#endif
				//#ifdef H5
				padding-top: 110rpx;
				//#endif







			}

			.set_list {
				//#ifdef APP-PLUS
				padding: 0rpx 20rpx 0;
				//#endif
				//#ifdef H5
				padding: 0rpx 20rpx 0;
				//#endif

				box-sizing: border-box;


				.item {
					width: 100%;
					height: auto;
					margin-top: 78rpx;
					padding: 70rpx 12rpx 15rpx 25rpx;
					box-sizing: border-box;
					background: #FAC11C;
					border-radius: 30rpx;
					position: relative;
					.top {
						max-width: 400rpx;
						min-width: 282rpx;
						height: 77rpx;
						line-height: 65rpx;
						text-align: center;
						border-radius: 10px;
						border: 2rpx solid #231815;
						padding: 6rpx 8rpx;
						box-sizing: border-box;
						background-color: #FFFFFF;
						position: absolute;
						left: 50%;
						transform: translateX(-50%);
						top: -39rpx;
						.contents {
							width: 100%;
							height: 100%;
							background-color: #FAC11C;
							position: relative;
							border-radius: 16rpx;
							color: #333333;
							font-size: 36rpx;
							font-weight: bold;
							padding: 0 20rpx;
							box-sizing: border-box;
							word-break: keep-all;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;

							&::after {
								content: '';
								height: 40rpx;
								border: 2rpx dashed #231815;
								position: absolute;
								left: 10rpx;
								top: 50%;
								transform: translateY(-50%);
							}

							&::before {
								content: '';
								height: 40rpx;
								border: 2rpx dashed #231815;
								position: absolute;
								right: 10rpx;
								top: 50%;
								transform: translateY(-50%);
							}
						}
					}

					.boxs {
						width: 100%;
						height: auto;
						display: flex;
						justify-content: space-between;
						align-items: center;
						flex-wrap: wrap;


						.items {
							width: calc((100% - 12rpx * 3) / 3);
							height: auto;
							padding-bottom: 12rpx;
							box-sizing: border-box;
							background-color: #FFFFFF;
							border-radius: 10rpx;
							margin: 0 12rpx 10rpx 0;

							image {
								width: 100%;
								height: 152rpx;
								border-radius: 10rpx 10rpx 0 0;
							}

							.product {
								padding: 0 10rpx 10rpx;
								box-sizing: border-box;

								.names {
									color: $uni-text-color;
									font-size: 20rpx;
									line-height: 28rpx;
									text-overflow: -o-ellipsis-lastline;
									overflow: hidden;
									text-overflow: ellipsis;
									display: -webkit-box;
									-webkit-line-clamp: 2;
									line-clamp: 2;
									-webkit-box-orient: vertical;
								}

								.price {
									margin-top: 14rpx;
									display: flex;
									justify-content: space-between;
									align-items: center;

									text {
										display: inline-block;
									}

									.tag {
										color: #FA8F1C;
										font-size: 18rpx;
										display: inline-block;
										word-break: keep-all;
										white-space: nowrap;
										overflow: hidden;
										text-overflow: ellipsis;
										max-width: 120rpx;
									}

									.money {
										padding: 5rpx 10rpx;
										box-sizing: border-box;
										width: auto;
										height: 28rpx;
										background: #FA8F1C;
										color: #FFFFFF;
										font-size: 24rpx;
										border-radius: 14rpx;
										display: flex;
										justify-content: center;
										align-items: center;

										.text {
											font-size: 20rpx;
										}
									}
								}
							}

						}
					}

					.boxs:after {
						content: "";
						flex: auto;
					}
				}

			}

		}

		.mores {
			// padding-top: 160rpx;
			position: relative;
		}
	}
</style>
